| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | Static Public Member Functions | List of all members
nkInputs::GamepadDevice Class Referenceabstract

A device abstracting a gamepad controller. More...

## Public Member Functions
| GamepadDevice (System *system) noexcept
virtual | ~GamepadDevice ()
System * | getSystem () const
virtual GamepadJoystickStatus | getLeftJoystickStatus () const =0
virtual GamepadJoystickStatus | getRightJoystickStatus () const =0
virtual float | getLeftTriggerStatus () const =0
virtual float | getRightTriggerStatus () const =0
virtual bool | isButtonDown (GAMEPAD_DEVICE_BUTTON button) const =0
virtual void | setGamepadSlot (unsigned int v)=0
virtual void | setLeftJoystickDeadzone (float v)=0
virtual void | setRightJoystickDeadzone (float v)=0
virtual void | setTriggersDeadzone (float v)=0
virtual void | setLeftMotorVibration (float v)=0
virtual void | setRightMotorVibration (float v)=0
virtual void | update ()=0

## Static Public Member Functions
static nkMemory::UniquePtr< GamepadDevice > | create (System *system=nullptr)

## Detailed Description

A device abstracting a gamepad controller.

First implemented on modern gamepads, making its interface following more closely their design. Typical usage looks like :

device->update() ;
float triggerState = device->getLeftTriggerStatus() ;
...

## Constructor & Destructor Documentation

## ◆ GamepadDevice()

nkInputs::GamepadDevice::GamepadDevice | ( | System * | system | ) |
| noexcept

Constructor. Used internally, for creation the create() method should be called.

Parameters

  system | The system to link the device to.

## ◆ ~GamepadDevice()

virtual nkInputs::GamepadDevice::~GamepadDevice | ( |  | ) |
| virtual

Destructor.

## Member Function Documentation

## ◆ getSystem()

System* nkInputs::GamepadDevice::getSystem | ( |  | ) | const

Returns
  The system the device is linked to.

## ◆ getLeftJoystickStatus()

virtual GamepadJoystickStatus nkInputs::GamepadDevice::getLeftJoystickStatus | ( |  | ) | const
| pure virtual

Returns
  The current left joystick's status.

## ◆ getRightJoystickStatus()

virtual GamepadJoystickStatus nkInputs::GamepadDevice::getRightJoystickStatus | ( |  | ) | const
| pure virtual

Returns
  The current right joystick's status.

## ◆ getLeftTriggerStatus()

virtual float nkInputs::GamepadDevice::getLeftTriggerStatus | ( |  | ) | const
| pure virtual

Returns
  The current left trigger's status.

Remarks
  The value will be given between 0 (fully released) and 1 (fully pressed).

## ◆ getRightTriggerStatus()

virtual float nkInputs::GamepadDevice::getRightTriggerStatus | ( |  | ) | const
| pure virtual

Returns
  The current right trigger's status.

Remarks
  The value will be given between 0 (fully released) and 1 (fully pressed).

## ◆ isButtonDown()

virtual bool nkInputs::GamepadDevice::isButtonDown | ( | GAMEPAD_DEVICE_BUTTON | button | ) | const
| pure virtual

Parameters

  button | The button which state should be retrieved.

Returns
  Whether the button is down, or pressed (true) or not (false).

## ◆ setGamepadSlot()

virtual void nkInputs::GamepadDevice::setGamepadSlot | ( | unsigned int | v | ) |
| pure virtual

Sets the gamepad slot the device should track. Modern gamepads connect to four different slots that can be tracked by using their index within [0, 3]. Defaults to 0.

Parameters

  v | The gamepad slot to use.

## ◆ setLeftJoystickDeadzone()

virtual void nkInputs::GamepadDevice::setLeftJoystickDeadzone | ( | float | v | ) |
| pure virtual

Sets the deadzone the left joystick should use. The deadzone corresponds to the amplitude of movement from the stick that won't trigger any reaction from the device. Defaults to 0.239.

Parameters

  v | The value for the deadzone, between [0, 1].

## ◆ setRightJoystickDeadzone()

virtual void nkInputs::GamepadDevice::setRightJoystickDeadzone | ( | float | v | ) |
| pure virtual

Sets the deadzone the right joystick should use. The deadzone corresponds to the amplitude of movement from the stick that won't trigger any reaction from the device. Defaults to 0.265.

Parameters

  v | The value for the deadzone, between [0, 1].

## ◆ setTriggersDeadzone()

virtual void nkInputs::GamepadDevice::setTriggersDeadzone | ( | float | v | ) |
| pure virtual

Sets the deadzone the triggers should use. The deadzone corresponds to the amplitude of movement from the triggers that won't trigger any reaction from the device. Defaults to 0.117.

Parameters

  v | The value for the deadzone, between [0, 1].

## ◆ setLeftMotorVibration()

virtual void nkInputs::GamepadDevice::setLeftMotorVibration | ( | float | v | ) |
| pure virtual

Sets the vibration level for the left motor. On modern gamepads, the left motor corresponds to the low frequency vibrations.

Parameters

  v | The strength for the vibration, between [0, 1].

## ◆ setRightMotorVibration()

virtual void nkInputs::GamepadDevice::setRightMotorVibration | ( | float | v | ) |
| pure virtual

Sets the vibration level for the right motor. On modern gamepads, the right motor corresponds to the high frequency vibrations.

Parameters

  v | The strength for the vibration, between [0, 1].

## ◆ update()

virtual void nkInputs::GamepadDevice::update | ( |  | ) |
| pure virtual

Updates the device to gather its latest status.

## ◆ create()

static nkMemory::UniquePtr<GamepadDevice> nkInputs::GamepadDevice::create | ( | System * | system = `nullptr` | ) |
| static

Creates a standalone device, linking it to a system, but no manager. This method can be used to allocate a device and manually manage its lifetime.

Parameters

  system | The system to create the device into. If left to nullptr, then the Singleton instance will be used.

Returns
  The created device instance.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsInputs/Devices/Gamepads/GamepadDevice.h